package edu.nctu.csie.jichang.dp.structural;

public class AdapterObject {
	public static void main(String[] args) {
		USBInterface tInterface = new ClassUsb();
		tInterface.open();
		tInterface.read();
		tInterface.close();
		tInterface = new ClassDiskAdapter(new ClassDisk());
		tInterface.open();
		tInterface.read();
		tInterface.close();
	}
}
interface USBInterface{
	void open();
	void read();
	void close();
}
class ClassDiskAdapter implements USBInterface{
	ClassDisk disk;
	ClassDiskAdapter(ClassDisk disk){
		this.disk = disk;
	}
	public void open() {disk.create();}
	public void read() {disk.look();}
	public void close() {disk.close();}
}
class ClassUsb implements USBInterface{
	public void open() { System.out.println("Usb open");}
	public void read() { System.out.println("Usb read");}
	public void close() { System.out.println("Usb close");}
}
class ClassDisk{
	void create() { System.out.println("Disk open");}
	void look() { System.out.println("Disk read");}
	void close() { System.out.println("Disk close");}
}
